package com.BraveY.Demo10;

import java.util.ArrayList;
import java.util.stream.Stream;

public class Demo09 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();

        list.add("林青霞");
        list.add("张曼玉");
        list.add("王祖贤");
        list.add("柳岩");
        list.add("张敏");
        list.add("张无忌");

        list.stream().filter(s -> s.startsWith("张")).forEach(System.out::println);
        System.out.println("------");
        list.stream().filter(s -> s.length() == 3).forEach(System.out::println);
        System.out.println("------");
        list.stream().filter(s -> s.length() == 3).filter(s -> s.startsWith("张")).forEach(System.out::println);
        System.out.println("------");

        Stream<String> s1 = list.stream().limit(4);
        Stream<String> s2 = list.stream().skip(2);
        Stream.concat(s1,s2).distinct().forEach(System.out::println);
        System.out.println("------");

        long count = list.stream().filter(s -> s.startsWith("张")).count();
        System.out.println(count);
    }
}
